package app.qrcode.browser.chat

import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.util.Log
import app.qrcode.browser.chat.model.EventListener
import com.hyphenate.chat.EMClient
import com.hyphenate.chat.EMOptions

/**
 * Created by DomenCai on 2022/2/24.
 */
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        context = applicationContext
        init()
    }

    companion object {
        @SuppressLint("StaticFieldLeak")
        lateinit var context: Context
    }


    private fun init() {

        val options = EMOptions()
        options.acceptInvitationAlways = false
        options.autoTransferMessageAttachments = true
        options.setAutoDownloadThumbnail(true)
        options.autoLogin = true

        EMClient.getInstance().init(applicationContext, options)
        EMClient.getInstance().setDebugMode(true)
        Log.w("cdm", "MyApplication.initMob -> 环信SDK初始化成功！")
        EventListener(context)
        Log.w("cdm", "MyApplication.init -> 全局联系人监听已开启！")
    }
}